const express = require('express');
const cors = require('cors');
const app = express();
const productRouter = require('./routes/product');
const programmeRouter = require('./routes/programme');
const customerRouter = require('./routes/customer');
const consultRouter = require('./routes/consult');
const newsRouter = require('./routes/news');
const joinRouter = require('./routes/join');

app.listen(3000,()=>{
    console.log('启动成功');
});

app.use(express.urlencoded({
    extended: true
}))
app.use(cors())

app.use('/v1/product',productRouter);
app.use('/v1/programme',programmeRouter);
app.use('/v1/customer',customerRouter);
app.use('/v1/consult',consultRouter);
app.use('/v1/news',newsRouter);
app.use('/v1/join',joinRouter)

app.use((err,req,res,next)=>{
    console.log(err);
    res.send({code:500,msg:'服务器错误'});
});